﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using System.Windows.Media.Imaging;
using System.Device.Location;
namespace MyUtility
{
    public partial class TakePhtoPage : PhoneApplicationPage
    {
        public TakePhtoPage()
        {
            InitializeComponent();
        }

        private void captureButton_Click(object sender, System.EventArgs e)
        {
        	// TODO: Add event handler implementation here.
			CameraCaptureTask capture = new CameraCaptureTask();
			capture.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhotoResult>(capture_Completed);
			capture.Show();
        }

        private void capture_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
        {
        	// TODO: Add event handler implementation here.
			if(e.TaskResult == TaskResult.OK){
				//using System.Windows.Media.Imaging;
				myImage.Source = new BitmapImage(new Uri(e.OriginalFileName,UriKind.Absolute));
			}
        }

        private void cameraRollButton_Click(object sender, System.EventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhotoChooserTask photo = new PhotoChooserTask();
			photo.ShowCamera = true;
			photo.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhotoResult>(photo_Completed);
			photo.Show();
        }

        private void photo_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
        {
        	// TODO: Add event handler implementation here.
			
			if(e.TaskResult == TaskResult.OK){
				//using System.Windows.Media.Imaging;
				myImage.Source = new BitmapImage(new Uri(e.OriginalFileName,UriKind.Absolute));
			}
        }

        private void captureMenuItem_Click(object sender, System.EventArgs e)
        {
        	// TODO: Add event handler implementation here.
			CameraCaptureTask capture = new CameraCaptureTask();
			capture.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhotoResult>(capture_Completed);
			capture.Show();
        }

        private void cameraRollMenuItem_Click(object sender, System.EventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhotoChooserTask photo = new PhotoChooserTask();
			photo.ShowCamera = true;
			photo.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhotoResult>(photo_Completed);
			photo.Show();
        }

        private void shareButton_Click(object sender, System.EventArgs e)
        {
        	// TODO: Add event handler implementation here.
			/*
			ShareLinkTask share = new ShareLinkTask();
			share.LinkUri = new Uri("http://www.bing.com");
			share.Message = "Hello Windows Phone";
			share.Title = "Test Share Link";
			share.Show();
			*/
			
			BingMapsDirectionsTask map = new BingMapsDirectionsTask();
			//16.4341 /  102.8361
  			//16.4301 /  102.8442
			map.Start = new LabeledMapLocation("From ",new GeoCoordinate(16.4341,102.8361));
			map.End = new LabeledMapLocation("To ",new GeoCoordinate(16.4301,102.8442));
			map.Show();
        }
    }
}
